<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body> 
            <?php
             include "/includes/ketnoi.php";
            $baitren_mottrang = 5;
            if (!isset($_GET['page'])) {
                $page = 1;
            } else {
                $page = $_POST['page'];
            }
            $sodu_lieu = mysqli_num_rows($conn->query("SELECT * FROM `jobs` ")) or die(mysql_error());
            //$sodu_lieu = mysqli_affected_rows($conn->query("SELECT * FROM `jobs` ")) or die(mysql_error());
            $sotrang = $sodu_lieu / $baitren_mottrang;
            $huuha = $page * $baitren_mottrang;
            //$result = $conn->query("SELECT * FROM `jobs` LIMIT $huuha,5 ") or die(mysql_error());
            //$result = $conn->query("SELECT jobs.id,branch.name as type_branch,locations.name as type_locations,users.email as type_users,jobs.title,jobs.content,jobs.salary_exp,jobs.expire_at FROM users INNER JOIN (locations INNER JOIN (branch INNER JOIN jobs ON branch.id = jobs.branch_id) ON locations.id = jobs.location_id) ON users.id = jobs.user_id; LIMIT $huuha,5;") or die(mysql_error());
            $result = $conn->query("SELECT jobs.id,branch.name as type_branch,locations.name as type_locations,users.email as type_users,jobs.title,jobs.content,salary,exp FROM users INNER JOIN (locations INNER JOIN (branch INNER JOIN jobs ON branch.id = jobs.branch_id) ON locations.id = jobs.location_id) ON users.id = jobs.user_id") or die(mysql_error());
                    
            while ($info = mysqli_fetch_array($result)) {
                echo'<table border="1">';
                echo'<tr>';
                echo'<td colspan="5" class="title">';
                echo $info['id'];
                echo "<br>";
                
                echo $info['type_branch'];
                echo "<br>";
                
                echo $info['type_locations'];
                echo "<br>";
                
                echo $info['type_users'];
                echo "<br>";
                
                echo $info['title'];
                echo "<br>";
                
                echo $info['content'];
                echo "<br>";
                
                echo $info['salary'];
                echo "<br>";
                
                echo $info['exp'];
                echo "<br>";

                /*echo'<table border="1">';
                echo'<tr>';
                echo'<td colspan="5" class="title">';
                
                echo $info['title'];
                echo "<br>";
                echo "<br>";
                echo $info['content'];*/

                echo "<br>";
                echo'</td>';
                echo'</tr>';
            }
            for ($page = 1; $page <= $sotrang; $page ++) {
                echo "<a href='PhanTrangCongViec.php?page={$page}'>{$page}</a>";
            }
            ?>
    </body>
</html>
